Country Required Mod v1.10
Author: xandra
Email: xknaff@hotpop.com

PHP-Fusion Copyright © 2002 - 2005 Nick Jones
Released under the terms & conditions of v2 of the GNU General Public License. For details refer to the included gpl.txt file or visit http://gnu.org

Description:
This mod will make location a required field in both registration and user profile. A selection menu containing a list of countries will replace the original text area and users will be required to select their country from that list during registration.

Questions?
Post them at http://phpfusion-mods.com or http://www.php-fusion.co.uk.

Installation Instructions:
Backup your website before uploading or modifying any files.
Step 1: Upload the contents of the php-files folder to the appropriate directory on your website.

Step 2: Choose either Option 1 or Option 2 below...

This package may or may not include modified files for your specific php-fusion version.

Do NOT use the modified files from this package if you have modified any of the above files on your site. Instead, follow the mod instructions provided below.
Option 1: If you have not modified any of the above files on your site, you should be able to use the included files without any problems. Check the mod folder to see if there is a folder that corresponds with your php-fusion version number. If so, upload the contents of that folder to the appropriate directories on your site and installation will be complete.
Option 2: If there are no files included for your specific php-fusion version or you have modified any of the above files on your site, you will need to modify your existing files using the mod instructions below.

Mod Instructions:
The instructions below are for PHP-Fusion v6.00.206, but may work on earlier or later versions.

Open includes/update_profile_include.php

Find...

if ($username == "" || $_POST['user_email'] == "") {

REPLACE with...

if ($username == "" || $_POST['user_email'] == "" || $_POST['user_location'] == "") {

Find...

$user_location = isset($_POST['user_location']) ? stripinput(trim($_POST['user_location'])) : "";

REPLACE with...

$user_location = stripinput(trim($_POST['user_location']));

Save and close.

Open locale/English/members-profile.php

Find...

$locale['480'] = "You must specify a user name & email address.";

REPLACE with...

$locale['480'] = "You must specify a user name, email address & location.";

Save and close.

Open locale/English/register.php

Find...

$locale['402'] = "You must specify a user name, password & email address.";

REPLACE with...

$locale['402'] = "You must specify a user name, password, email address & location.";

Find...

$locale['552'] = "Please specify an email address.";

ADD below it...

$locale['553'] = "Please specify a location.";

Save and close.

Open edit_profile.php

Find...

<td class='tbl'>".$locale['u009']."</td>
<td class='tbl'><input type='text' name='user_location' value='".$userdata['user_location']."' maxlength='50' class='textbox' style='width:200px;'></td>

REPLACE both lines with...

<td class='tbl'>".$locale['u009']."<span style='color:#ff0000'>*</span></td>
<td class='tbl'>
<select name='user_location' class='textbox' style='width:200px;'>
<option value=''></option>\n";

	include INCLUDES."countries.php";
	sort($countries);
	reset($countries);

	foreach ($countries as $country) {
		echo "<option value='$country'".($userdata['user_location'] == $country ? " selected" : "").">$country</option>";
	}
	
	echo "</select></td>

Save and close.

Open register.php

Find...

$result = dbquery("INSERT INTO ".$db_prefix."users VALUES('', '".$user_info['user_name']."', '".md5($user_info['user_password'])."', '".$user_info['user_email']."', '".$user_info['user_hide_email']."', '', '0000-00-00', '', '', '', '', '', 'Default', '0', '', '', '0', '".time()."', '0', '".USER_IP."', '', '', '101', '$activation')");

REPLACE with...

$result = dbquery("INSERT INTO ".$db_prefix."users VALUES('', '".$user_info['user_name']."', '".md5($user_info['user_password'])."', '".$user_info['user_email']."', '".$user_info['user_hide_email']."', '".$user_info['user_location']."', '0000-00-00', '', '', '', '', '', 'Default', '0', '', '', '0', '".time()."', '0', '".USER_IP."', '', '', '101', '$activation')");

Find...

$password1 = stripinput(trim(eregi_replace(" +", "", $_POST['password1'])));

ADD below it...

$user_location = stripinput(trim($_POST['user_location']));

Find...

if ($username == "" || $password1 == "" || $email == "") $error .= $locale['402']."<br>\n";

REPLACE with...

if ($username == "" || $password1 == "" || $email == "" || $user_location == "") $error .= $locale['402']."<br>\n";

Find and DELETE...

$user_location = isset($_POST['user_location']) ? stripinput(trim($_POST['user_location'])) : "";

Find...

"user_hide_email" => isNum($_POST['user_hide_email']) ? $_POST['user_hide_email'] : "1"

REPLACE with...

"user_hide_email" => isNum($_POST['user_hide_email']) ? $_POST['user_hide_email'] : "1",
"user_location" => $user_location

Find...

</tr>\n";
	if ($settings['display_validation'] == "1") {

REPLACE both lines with...

</tr>
<tr>
<td class='tbl'>".$locale['u009']."<span style='color:#ff0000'>*</span></td>
<td class='tbl'>
<select name='user_location' class='textbox' style='width:200px;'>
<option value=''></option>\n";
			
	include INCLUDES."countries.php";
	sort($countries);
	reset($countries);

	foreach ($countries as $country) {
		echo "<option value='$country'>$country</option>";
	}
			
	echo "</select></td>
</tr>\n";
			
	if ($settings['display_validation'] == "1") {

Find and DELETE the red text...

	if ($settings['email_verification'] == "0") {
		echo "<tr>
<td class='tbl'>".$locale['u009']."</td>
<td class='tbl'><input type='text' name='user_location' maxlength='50' class='textbox' style='width:200px;'></td>
</tr>
<tr>
<td class='tbl'>".$locale['u010']." <span class='small2'>(mm/dd/yyyy)</span></td>

Find...

	if (frm.email.value==\"\") {
		alert(\"".$locale['552']."\");
		return false;
	}

ADD below it...

	if (frm.user_location.value==\"\") {
		alert(\"".$locale['553']."\");
		return false;
	}

Save and close.


Change Log: